<?php
include_once 'Hasher.php';

class User {

	private $id;
	private $login;
	private $hash_password;
	private $mail;
	private $path_to_avatar;

	public function __construct() {
		$this->id=-1;
		$this->login="";
		$this->hashPassword="";
		$this->mail="";
		$this->pathToAvatar="";
	}

	public function __destruct() {}
	
	public function  getId() {
		return $this->id;
	}

	public function setId($id) {
		$this->id=$id;
	}

	public function  getLogin() {
		return $this->login;
	}

	public function setLogin($login) {
		$this->login=$login;
	}

	public function getPassHash() {
		return $this->hashPassword;
	}

	public function setPass($password) {
		$this->hashPassword = Hasher::hash($password);
	}
	
	public function setPassHash($passwordHash) {
		$this->hashPassword = $passwordHash;
	}

	public function setMail($mail) {
		$this->mail=$mail;
	}

	public function  getMail() {
		return $this->mail;
	}

	public function  getAvatar() {
		return $this->pathToAvatar;
	}

	public function setAvatar($avatar) {
		$this->pathToAvatar=$avatar;
	}

	public function __toString() {
		$str_id='['.$this->id.'] - ';
		$str='Login:<b>'.$this->login.'</b><br />ID: '.$this->id.'<br />E-Mail:'.$this->mail.'<br />Avatar: '
			.$this->pathToAvatar.'<br /> Password Hash: '.$this->hashPassword.'<br />';
		return $str;
	}
	
	public function getUserStatement() {
		return "SELECT * FROM user WHERE login=?";
	}
	
	public function getAddUserStatement() {
		return "INSERT INTO user(id, login, password, mail, avatar) VALUES (DEFAULT, ?,?,?,?)";
	}
	
	public function getUserByIdStatement() {
		return "SELECT * FROM user WHERE id=?";
	}
	
	public function getChangePasswordStatement() {
		return "UPDATE user SET password=? WHERE id=?";					
	}
	
	public function getChangeAvatarStatement() {
		return "UPDATE user SET avatar=? WHERE id=?";					
	}
}

?>